package com.java110.mall.shop.smo.impl;


import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.vipUser.ShopVipUserDto;
import com.java110.intf.shop.IShopVipUserInnerServiceSMO;
import com.java110.po.shop.ShopVipUserPo;
import com.java110.mall.shop.dao.IShopVipUserServiceDao;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 商铺会员内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopVipUserInnerServiceSMOImpl extends BaseServiceSMO implements IShopVipUserInnerServiceSMO {

    @Autowired
    private IShopVipUserServiceDao shopVipUserServiceDaoImpl;


    @Override
    public int saveShopVipUser(@RequestBody ShopVipUserPo shopVipUserPo) {
        int saveFlag = 1;
        shopVipUserServiceDaoImpl.saveShopVipUserInfo(BeanConvertUtil.beanCovertMap(shopVipUserPo));
        return saveFlag;
    }

    @Override
    public int updateShopVipUser(@RequestBody ShopVipUserPo shopVipUserPo) {
        int saveFlag = 1;
        shopVipUserServiceDaoImpl.updateShopVipUserInfo(BeanConvertUtil.beanCovertMap(shopVipUserPo));
        return saveFlag;
    }

    @Override
    public int deleteShopVipUser(@RequestBody ShopVipUserPo shopVipUserPo) {
        int saveFlag = 1;
        shopVipUserPo.setStatusCd("1");
        shopVipUserServiceDaoImpl.updateShopVipUserInfo(BeanConvertUtil.beanCovertMap(shopVipUserPo));
        return saveFlag;
    }

    @Override
    public List<ShopVipUserDto> queryShopVipUsers(@RequestBody ShopVipUserDto shopVipUserDto) {

        //校验是否传了 分页信息

        int page = shopVipUserDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopVipUserDto.setPage((page - 1) * shopVipUserDto.getRow());
        }

        List<ShopVipUserDto> shopVipUsers = BeanConvertUtil.covertBeanList(shopVipUserServiceDaoImpl.getShopVipUserInfo(BeanConvertUtil.beanCovertMap(shopVipUserDto)), ShopVipUserDto.class);

        return shopVipUsers;
    }


    @Override
    public int queryShopVipUsersCount(@RequestBody ShopVipUserDto shopVipUserDto) {
        return shopVipUserServiceDaoImpl.queryShopVipUsersCount(BeanConvertUtil.beanCovertMap(shopVipUserDto));
    }

    public IShopVipUserServiceDao getShopVipUserServiceDaoImpl() {
        return shopVipUserServiceDaoImpl;
    }

    public void setShopVipUserServiceDaoImpl(IShopVipUserServiceDao shopVipUserServiceDaoImpl) {
        this.shopVipUserServiceDaoImpl = shopVipUserServiceDaoImpl;
    }
}
